package com.example.trackcircuitdiagnosis.controller;

import com.example.trackcircuitdiagnosis.entity.DataAnalongTableEntity;
import com.example.trackcircuitdiagnosis.exception.HttpResult;
import com.example.trackcircuitdiagnosis.exception.HttpResultGenerator;
import com.example.trackcircuitdiagnosis.service.DataAnalogService;
import com.example.trackcircuitdiagnosis.service.DataAnalongTableService;
import com.example.trackcircuitdiagnosis.time.MyScheduledTask;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;


@RestController
@CrossOrigin
@RequestMapping("/data_analog")
public class DataAnalogTableController {


    @Autowired
    private DataAnalogService dataAnalogService;


    @Autowired
    private DataAnalongTableService dataAnalongTableService;
    // 新增或者更新
    @Autowired
    private MyScheduledTask myScheduledTask;

    @GetMapping("/startTask/{sendTime}")
    @Operation(
            description = "定时任务管理",
            parameters = {
                    @Parameter(name = "sendTime", description = "发送的时间点"),
            }

    )
    public HttpResult startTask(@PathVariable(value = "sendTime") int sendTime) {
        myScheduledTask.setTaskRunning(true);
        myScheduledTask.setSendTime(sendTime);
        return HttpResultGenerator.success("设置成功");
    }

    @GetMapping("/dataAnalogALl/{mid}")
    @Operation(description = "获取模拟量和开关量信息",
            parameters = {
            @Parameter(name = "mid", description = "查找的检测项目id,1是zpw2000a,2是25HZ")
    })
    public List<DataAnalongTableEntity> findDataAnalogTableAll(@PathVariable Integer mid) {
        return dataAnalongTableService.dataAnalogALl(mid);

    }

}

